bitkeeper revision 1.1236.52.1 (424d53535i5qoHsSZWrLD8tQJZG12w)
authorkaf24@firebug.cl.cam.ac.uk <kaf24@firebug.cl.cam.ac.uk>
Fri, 1 Apr 2005 13:57:39 +0000 (13:57 +0000)
committerkaf24@firebug.cl.cam.ac.uk <kaf24@firebug.cl.cam.ac.uk>
Fri, 1 Apr 2005 13:57:39 +0000 (13:57 +0000)
Fix FS/GS saving on Linux 2.6.
Signed-off-by: Keir Fraser <keir@xensource.com>
linux-2.6.11-xen-sparse/arch/xen/i386/kernel/process.c
linux-2.6.11-xen-sparse/include/asm-xen/asm-i386/mmu_context.h

index e8f169fbca76ff6b807ba8e37b90c8f192b2f2c2..99cba038fc0a13cc0f9acb04332997ec07e65517 100644 (file)
@@ -445,22 +445,7 @@ struct task_struct fastcall * __switch_to(struct task_struct *prev_p, struct tas
        physdev_op_t iopl_op, iobmp_op;
        multicall_entry_t _mcl[8], *mcl = _mcl;
 
-       /*
-        * Save away %fs and %gs. No need to save %es and %ds, as
-        * those are always kernel segments while inside the kernel.
-        */
-       asm volatile("movl %%fs,%0":"=m" (*(int *)&prev->fs));
-       asm volatile("movl %%gs,%0":"=m" (*(int *)&prev->gs));
-
-       /*
-        * We clobber FS and GS here so that we avoid a GPF when restoring
-        * previous task's FS/GS values in Xen when the LDT is switched.
-        */
-       __asm__ __volatile__ ( 
-               "xorl %%eax,%%eax; movl %%eax,%%fs; movl %%eax,%%gs" : : :
-               "eax" );
-
-       /* never put a printk in __switch_to... printk() calls wake_up*() indirectly */
+        /* XEN NOTE: FS/GS saved in switch_mm(), not here. */
 
        /*
         * This is basically '__unlazy_fpu', except that we queue a
index de53523986ee8f4f8b0a28bf4fd0f99efbabdeb1..4263f25ac5b7d50f9ce7bb45a86442507a92bc02 100644 (file)
@@ -16,13 +16,31 @@ void destroy_context(struct mm_struct *mm);
 
 static inline void enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk)
 {
-#ifdef CONFIG_SMP
+#if 0 /* XEN */
        unsigned cpu = smp_processor_id();
        if (per_cpu(cpu_tlbstate, cpu).state == TLBSTATE_OK)
                per_cpu(cpu_tlbstate, cpu).state = TLBSTATE_LAZY;
 #endif
 }
 
+#define prepare_arch_switch(rq,next)   __prepare_arch_switch()
+#define finish_arch_switch(rq, next)   spin_unlock_irq(&(rq)->lock)
+#define task_running(rq, p)            ((rq)->curr == (p))
+
+static inline void __prepare_arch_switch(void)
+{
+       /*
+        * Save away %fs and %gs. No need to save %es and %ds, as those
+        * are always kernel segments while inside the kernel. Must
+        * happen before reload of cr3/ldt (i.e., not in __switch_to).
+        */
+       __asm__ __volatile__ ( "movl %%fs,%0 ; movl %%gs,%1"
+               : "=m" (*(int *)&current->thread.fs),
+                 "=m" (*(int *)&current->thread.gs));
+       __asm__ __volatile__ ( "movl %0,%%fs ; movl %0,%%gs"
+               : : "r" (0) );
+}
+
 static inline void switch_mm(struct mm_struct *prev,
                             struct mm_struct *next,
                             struct task_struct *tsk)
@@ -32,7 +50,7 @@ static inline void switch_mm(struct mm_struct *prev,
        if (likely(prev != next)) {
                /* stop flush ipis for the previous mm */
                cpu_clear(cpu, prev->cpu_vm_mask);
-#ifdef CONFIG_SMP
+#if 0 /* XEN */
                per_cpu(cpu_tlbstate, cpu).state = TLBSTATE_OK;
                per_cpu(cpu_tlbstate, cpu).active_mm = next;
 #endif
@@ -47,7 +65,7 @@ static inline void switch_mm(struct mm_struct *prev,
                if (unlikely(prev->context.ldt != next->context.ldt))
                        load_LDT_nolock(&next->context, cpu);
        }
-#ifdef CONFIG_SMP
+#if 0 /* XEN */
        else {
                per_cpu(cpu_tlbstate, cpu).state = TLBSTATE_OK;
                BUG_ON(per_cpu(cpu_tlbstate, cpu).active_mm != next);